import { MyVue } from 'src/wl/my_vue';
import Vue from 'vue';
import { Component, Emit, Prop, Provide, Watch } from 'vue-property-decorator'
import { AuditTConst } from "src/consts/audit_template_const";
@Component({})
export default class AuditTPanel extends MyVue {
    name: string = 'AuditTPanel';
    formData: any;
    footerFlag: boolean = true;
    title: String;
    titleIcon: String;
    featureCode: String;

    initData(that?: any): void {
        that.formData = WLStore().state.auditTShow;
        if (WLStore().state.auditTemplate.type == "edit") {
            that.title = "审核模版详情"
            that.titleIcon = "btn_xq"

        } else if (WLStore().state.auditTemplate.type == "add") {
            that.title = "新增审核模版"
            that.titleIcon = "pop_xz"
            that.formData.status = "qiyong"
        }
        that.featureCode = Config.featureCode + "audit.model.AuditFlowSettingView"
    }

    mounted(): void {
    }

    editAuditT(): void {
        this.$refs.auditTForm.validate((valid: Boolean) => {
            if (valid) {
                if (WLStore().state.auditTemplate.type == "edit") {
                    WLDispatch(AuditTConst.DispatchAuditTEdit, this.formData);
                } else if (WLStore().state.auditTemplate.type == "add") {
                    var sendData: any = this.formData
                    sendData.version = 1.0
                    delete sendData.bind_status
                    delete sendData.id
                    delete sendData.feature_code
                    WLDispatch(AuditTConst.DispatchAuditTAdd, sendData);
                }
            } else {
                if (WLStore().state.auditTemplate.type == "edit") {
                    WLMessage("必填字段为空,无法编辑审核模版", "warning")
                } else if (WLStore().state.auditTemplate.type == "add") {
                    WLMessage("必填字段为空,无法新增审核模版", "warning")
                }
                return false;
            }
        })
    }

    openBusiness(): void {
        WLDispatch(AuditTConst.DispatchBusinessList, this.formData);
    }
}